<template>
	<view>

		<view class="list">
			<view class="login">
				绑定手机号
			</view>
			<view class="pwd">
				<input type="text" class="input" v-model="listcode.phone" placeholder="请输入用户名">
				<view class="buttons">
					<input type="password" v-model="listcode.code" class="input" name="" id="" placeholder="请输入验证码">
					<button type="primary"  @click="phonelist" >验证码</button>
				</view>
			</view>
			<view class="button">
				<u-button type="#5ccc84" id="demo1" @click="add">绑定</u-button>
			</view>
		

		</view>
	</view>
</template>

<script>
	import {listPhone,addlistt} from "@/api/user.js"
	export default {
		data() {
			return {
				
				listcode:{
					phone:"",
					code:"",
				}
			}
		},
		methods: {
		async phonelist(){
				if(this.listcode.phone==""){
					uni.showToast({
						icon:"error",
						title:"请输入手机号"
					})
					return
				}
				console.log(1);
				const res=await listPhone(this.listcode)
				console.log(res);
				if(res.code=="20000"){
					uni.showToast({
						message:res.data
					})
				}
			},
			async add(){
				const res=await addlistt(this.listcode)
				console.log(res);
				if(res.msg=="ok"){
					uni.showToast({
						success:res.msg
					})
					uni.navigateTo({
						url:"/pages/login/login"
					})
				}
			}

		}
	}
</script>

<style scoped lang="scss">
	* {
		box-sizing: border-box;
	}

	.icon {
		width: 600rpx;
		height: 50rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		margin: auto;

	}

	.item {
		width: 600rpx;
		height: 100rpx;
		display: flex;
		align-items: center;
		margin: auto;
		justify-content: space-between;
		padding-left: 30rpx;
		padding-right: 30rpx;
		margin-top: 20rpx;

		p:nth-child(1) {
			color: green;
			font-size: 30rpx
		}

		p:nth-child(2) {
			font-size: 30rpx;
			color: gray;

		}
	}

	.button {
		width: 600rpx;
		height: 100rpx;
		margin: auto;
		background-color: yellow;
		margin-top: 20rpx;
		background-color: #5ccc84;
		color: white;

		#demo1 {
			width: 600rpx;
			height: 100rpx;
			font-size: 30rpx
		}
	}

	.list {
		width: 750rpx;
		height: 1000rpx;
		background-color: #fff;
		border-top-left-radius: 32px;
		border-top-right-radius: 32px;
		margin-top: -20rpx;

		.pwd {
			width: 600rpx;
			margin: auto;
			.buttons{
				display: flex;
			}

			button {
				width: 300rpx;
				height: 100rpx;
				margin-top: 30rpx;
				text-align: center;
				line-height: 100rpx;
			
			}

			.input {
				height: 100rpx;
				width: 600rpx;
				font-size: 30rpx;
				padding-left: 50rpx;
				margin-top: 30rpx;
				background-color: #F5F5F5;
			}
		}

		.login {
			width: 750rpx;
			height: 80rpx;
			display: flex;
			align-items: center;
			padding-left: 40rpx;
			font-size: 22px;
			color: #35404b;
		}
	}

	.header {
		width: 750rpx;
		height: 250rpx;
		background-image: linear-gradient(to right, #3DFCB1, #6ADAEA);

		p {
			padding-left: 34px;
			padding-top: 12px;
			font-size: 33px;
			color: white;
		}
	}
</style>
